home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PROGEDIT / 0748.ZIP / COMP < prev    next >
Text File  |  1986-12-29  |  1KB  |  73 lines

  1. #define ALT_C   174
  2. #define CTRL_N  14
  3.  
  4. #define NO      0
  5. #define YES     1
  6.  
  7.  
  8. int reached_eof;
  9.  
  10.  
  11. init()
  12. {
  13.   assign_key("compile",    ALT_C);
  14.   assign_key("next_error", CTRL_N);
  15. }
  16.  
  17. compile()
  18. {
  19.   string currfile;
  20.   int    errcode, i;
  21.   
  22.   currfile = filename();
  23.  
  24.   writefile(currfile);
  25.  
  26.   if ((i = index(currfile, ".")) > 0)
  27.     currfile = substr(currfile, 1, i - 1);
  28.  
  29.   errcode =
  30.     os_command(sprintf("lc1 -ccuw -d -ml -i\lc\ %s > errs", currfile));
  31.   if (!errcode)
  32.     errcode = os_command(sprintf("lc2 %s", currfile));
  33.   message(sprintf("The error code from the compile was %d", errcode));
  34.   get_tty_char();
  35.  
  36.   next_error();
  37. }
  38.  
  39. next_error()
  40. {
  41.   int id, old_id;
  42.   int n;
  43.   string cl, foo;
  44.  
  45.   old_id = currbuf();
  46.  
  47.   if ((id = find_buffer("errs")) == 0)
  48.   {
  49.     id = create_buffer("errs");
  50.     reached_eof = NO;
  51.   }
  52.   id = setcurrbuf(id);
  53.  
  54.   if (reached_eof == NO && fsearch("[0-9][0-9]* Error") > 0)
  55.   {
  56.     n = atoi(substr(cl = currline(), currcol(), 5));
  57.     gobol();
  58.     if (!down())
  59.       reached_eof = YES;
  60.     show_buffer(old_id);
  61.     goline(n);
  62.     message(cl);
  63.     get_tty_char();
  64.   }
  65.  
  66.   else
  67.   {
  68.     foo = get_tty_str("NO MORE ERRORS");
  69.     delete_buffer(id);
  70.     show_buffer(old_id);
  71.   }
  72. }
  73.